using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using Module.EntitiesInfo;

namespace Module.DataAccess
{
    public class CandidateExamDB
    {
        #region ConnectionString
        private string _connectionString;
        public string ConnectionString
        {
            get { return _connectionString; }
            set { _connectionString = value; }
        }
        public CandidateExamDB()
        {
            ConnectionString = ConfigurationManager.ConnectionStrings["localsql"].ToString();
        }
        #endregion

        public virtual void Delete(int id)
        {
            SqlParameter[] parameters = new SqlParameter[]
			{                
				new SqlParameter("@Id", id)
			};
            SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, "CandidateExams_Delete", parameters);
        }

        public virtual int Insert(CandidateExamInfo info)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
				new SqlParameter("@ExamId", info.ExamId),
				new SqlParameter("@CandId", info.CandId),
                new SqlParameter("@Status", info.Status),
				new SqlParameter("@StartDate", info.StartDate),
                new SqlParameter("@EndDate", info.EndDate),
				new SqlParameter("@CloseDate", info.CloseDate),
                new SqlParameter("@Choice1", info.Choice1),
				new SqlParameter("@Choice2", info.Choice2),
                new SqlParameter("@Choice3", info.Choice3),
				new SqlParameter("@Choice4", info.Choice4),
                new SqlParameter("@totalCorrect", info.TotalCorrect),
				new SqlParameter("@Score", info.Score)                
			};
            return (int)SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "CandidateExams_Insert", parameters);           
        }
     }
}

